package com.etc.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.etc.dao.impl.LeaveapprovallDaoImpl;
import com.etc.entity.LeaveApproval;
import com.etc.service.lLeaveapprovallService;

public class LeaveapprovallServicelmpl implements lLeaveapprovallService {
	LeaveapprovallDaoImpl dao=new LeaveapprovallDaoImpl();
	@Override
	public boolean getaddLeave(LeaveApproval leave) {
		
		return dao.addLeave(leave);
	}
	/**
	 * 获取待审批的请假条集合
	 * deptId:部门Id
	 * return:请假条集合
	 */
	@Override
	public List<LeaveApproval> getBeCorrectLeaveByDeptId(int deptId) {
		List<LeaveApproval> list = dao.queryLeaveByDeptId(deptId);
		List<LeaveApproval> l2 = new ArrayList<LeaveApproval>();
		for (LeaveApproval leave : list) {
			//if(leave.getResult() == 0) {
				l2.add(leave);
			//}
		}
		return l2;
	}
	
	/**
	 * 批准请假条
	 * approvalId:请假条id
	 * return:boolean值
	 */
	@Override
	public boolean approvalLeave(int approvalId) {
		return dao.updateLeaveResult(approvalId, 1);
	}
	
	/**
	 * 拒批请假条
	 * approvalId:请假条id
	 * return:boolean值
	 */
	@Override
	public boolean refuseLeave(int approvalId) {
		return dao.updateLeaveResult(approvalId, 2);
	}
	
	/**
	 * 获取自己提交的请假申请
	 * empId:自己id
	 * return:请假条集合
	 */
	@Override
	public List<LeaveApproval> getMyLeaveById(int empId) {
		return dao.queryMyLeaveById(empId);
	}

}
